/**
 * @description 用户关系api
 */

const router = require('koa-router')()
const { loginCheck } = require('../../middleware/loginCheck')
const { follow,unFollow } = require('../../control/userRelation')

router.prefix('/api')

// 关注
router.post('/follow',loginCheck,async (ctx,next) => {
  // 用户自己的id
  const { id: userId } = ctx.session.userInfo
  // 关注人的Id
  const { followerId } = ctx.request.body
  ctx.body = await follow(userId,followerId)
})
// 取消关注
router.post('/unFollow',loginCheck,async (ctx,next) => {
  // 用户自己的id
  const { id: userId } = ctx.session.userInfo
  // 关注人的Id
  const { followerId } = ctx.request.body
  ctx.body = await unFollow(userId,followerId)
})

// 获取粉丝列表
router.get('/getFans',loginCheck,async (ctx,next) => {
  let { followerId } = ctx.request.boyd
  ctx.body = await getFans(followerId)
})

module.exports = router